<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box{
        background-color: pink;
    }
    .box1{
        width: 300px;
        height: 300px;
        background-color: blue;
        float: left;
    }
    .box2{
        width: 300px;
        height: 300px;
        background-color: rgb(20, 212, 13);
        float: right;
        /* 一般不在这里写清除浮动 */
        /* clear: both; */
    }
    .box::after{
        content: "";
        clear: both;
        display: block;
    }
</style>
<body>
    <div class="box">
        <div class="box1"></div>
        <div class="box2"></div>
    </div>
</body>
</html>